import {useState,useEffect} from 'react'
import {CountAll} from '../../api/index'
import Countdown  from '../../hooks/useCut'
function HomeView() {
  // 统计数据
  const [data,setData] = useState({});
  const [remainingSeconds,startCountdown,resetCountdown] =Countdown(10,()=>{alert("abc")});
  // 组件挂载完毕获取统计的数据
  useEffect(()=>{
    CountAll()
    .then(res=>{
      // 更新视图与数据
      setData(res.data.data);
    })
  },[])
  return ( <div>
    <p>{remainingSeconds}</p>
    <button onClick={startCountdown}>start</button>
    <button onClick={resetCountdown}>reset</button>
    概览{JSON.stringify(data)}</div> );
}

export default HomeView;